package com.ibeeking.found.upms.s.rest.controller.v1;

import com.ibeeking.found.common.annotation.LoginUser;
import com.ibeeking.found.common.entity.CurrentUser;
import com.ibeeking.found.upms.s.rest.service.IShopUserRoleService;
import com.ibeeking.found.upms.service.common.param.RoleUserParam;
import com.ibeeking.found.upms.service.common.param.UserRoleParam;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName UserRoleController控制器
 * @Description 全局用户管理
 * @Author ibeeking
 * @Date 2020-12-02 15:29
 **/
@RestController
@RequestMapping("/b/userRole/v1")
public class ShopUserRoleController {

    @Resource
    private IShopUserRoleService shopUserRoleService;

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "通过用户Id关联用户角色")
    @PostMapping(value = "/modifyByUserId")
    public Boolean modifyByUserId(@LoginUser CurrentUser currentUser, @RequestBody @Validated UserRoleParam userRoleParam) {
        return shopUserRoleService.modifyUserRoleByUserId(currentUser, userRoleParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "通过角色Id关联用户")
    @PostMapping(value = "/modifyByRoleId")
    public Boolean modifyByRoleId(@LoginUser CurrentUser currentUser, @RequestBody @Validated RoleUserParam roleUserParam) {
        return shopUserRoleService.modifyUserRoleByRoleId(currentUser, roleUserParam);
    }
}
